﻿package command {
	import flash.text.TextField;
	
	public class FormatSelectCommand implements ICommand {
		private var inputField:TextField;
		private var block:Array;
		private var oldFormat:Array;
		private var newFormat:Array;
		
		public function FormatSelectCommand(inputField:TextField, block:Array, oldFormat:Array, newFormat:Array):void {
			this.inputField = inputField;
			this.block = block;
			this.oldFormat = oldFormat;
			this.newFormat = newFormat;
		}
		
		public function redo():void {
			for (var i:int = 0, count:int = 0; i < block.length; i += 2, count++) {
				inputField.setTextFormat(newFormat[count], block[i], block[i + 1]);
			}
		}
		public function undo():void {
			for (var i:int = 0, count:int = 0; i < block.length; i += 2, count++) {
				inputField.setTextFormat(oldFormat[count], block[i], block[i + 1]);
			}
		}
	}
}